export const Layout = () => import("@/layout/index.vue");

// 静态路由
const constantRoutes = [
    {
        path: "/",
        name: "Layout",
        component: Layout,
        redirect: "/dashboard",
        children: [
            {
                path: "/dashboard",
                component: () => import("@/views/dashboard/index.vue"),
                name: "dashboard",
                meta: {

                    title: "项目列表",
                    requiresAuth: true,
                    cache: true,
                    perms: [
                        "/index"
                    ],
                },
            },
            {
                path: '/product',
                name: 'Product',
                component: () => import('@/views/product/index.vue'),
                meta: {
                    title: '产品列表',
                    requiresAuth: true // ✅ 需要登录
                }
            },
            {
                path: '/user',
                name: 'User',
                component: () => import('@/views/user/index.vue'),
                meta: {
                    title: '用户管理',
                    requiresAuth: true, // ✅ 需要登录
                    adminOnly: true  // 只有 admin 能看见
                }
            },

        ]
    },
    {
        path: "/login",
        component: () => import("@/views/login/index.vue"),
        name: "login",
        meta: {
            title: "登录",
            requiresAuth: false, //
            cache: true,
        },
    },
    // 重定向页面 必须保留
    {
        path: "/redirect",
        component: Layout,
        meta: {
            hidden: true
        },
        children: [
            {
                path: ":path(.*)",
                component: () => import("@/views/sys/redirect/index.vue")
            }
        ]
    },

    {
        path: '/:pathMatch(.*)*',
        name: '404',
        component: () => import('@/views/sys/error-page/404.vue'),
        meta: {
            title: '404',
            hidden: true
        },
    }

]

// 重新组织后导出
export default [
    ...constantRoutes
]
